package com.mareas.web.service.impl;

import java.io.Serializable;
import java.util.List;

import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;

import org.springframework.stereotype.Service;

import com.mareas.web.dao.Dao;
import com.mareas.web.service.GenericService;

@Service
@ManagedBean
@ApplicationScoped
public class GenericServiceImpl implements GenericService {

	private Dao dao;

	public void persist(Object object) {
		dao.persist(object);
	}

	public <T> List<T> getAll(Class<T> entityClass) {
		final List<T> entities = dao.find(entityClass);
		return entities;
	}

	public <T> T get(Class<T> entityClass, Serializable id) {
		final T entity = (T) dao.load(entityClass, id);
		return entity;
	}

	public void remove(Object object) {
		dao.remove(object);
	}

	public Dao getDao() {
		return dao;
	}

	public void setDao(Dao dao) {
		this.dao = dao;
	}

}
